package com.geekjob1120.geekjob1120pay.modle;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.UpdateTimestamp;
import org.joda.money.Money;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name="t_pay",uniqueConstraints = @UniqueConstraint(name = "idx_orderId",columnNames = {"order_id"})
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(of = {"id"})
public class Pay {

    @GeneratedValue
    @Id
    private long id;
    @Column(updatable = false)
    @CreationTimestamp
    private Date createTime;
    @UpdateTimestamp
    private Date updateTime;
    private PayWay payway;
    private PayState state;
    @Column(name = "order_id")
    private String orderId;
    @Type(type = "org.jadira.usertype.moneyandcurrency.joda.PersistentMoneyAmount",
    parameters = {@org.hibernate.annotations.Parameter(name = "currencyCode",value = "CNY")})
    private Money amt;
    private String prodDesc;

}